import numpy as np
import os
import scipy.io as scio

def convert_npz_to_mat(data_dir):

    names = ['Adw', 'Drp', 'Rtk', 'Susp', 'Trj', 'CTU_Normal_vs_Adw_Drp_Rtk_Susp']
    alg = 'mv'

    for name in names:
        if name == 'CTU_Normal_vs_Adw_Drp_Rtk_Susp':
            data_name = 'CTU_Normal_vs_Adw_Drp_Rtk_Susp_{}_res.npz'.format(alg)
        else:
            data_name = 'CTU_Normal_vs_{}_{}_res.npz'.format(name, alg)
        data_path = data_dir + data_name
        if not os.path.exists(data_path):
            print(data_path, ' does not exist ...')
            continue

        data = np.load(data_path)
        mat_name = data_name[:-4] + '.mat'
        scio.savemat(mat_name, data)



if __name__ == '__main__':

    convert_npz_to_mat('../../res/')